#include <stdio.h>
#include<string.h>
#include<stdlib.h>

void transger_bin2pcd(char* filename)
{
	int num=1000000;
	float* data=(float*)malloc(sizeof(float)*num);
	float* px=data+0;
	float* py=data+1;
	float* pz=data+2;
	float* pr=data+3;

	FILE * out_stream;
	out_stream=fopen("test_out.pcd","wb");
	


	FILE* stream;
	stream=fopen(filename,"rb");
	num=fread(data,sizeof(float),num,stream)/4;


	fprintf(out_stream,"# .PCD v0.7 - Point Cloud Data file format\nVERSION 0.7\nFIELDS x y z\nSIZE 4 4 4\nTYPE F F F\nCOUNT 1 1 1\nWIDTH %d\nHEIGHT 1\nVIEWPOINT 0 0 0 1 0 0 0\nPOINTS %d\nDATA ascii\n",num,num );	


	for(int32_t i=0;i<num;i++)
	{
		// point_
		fprintf(out_stream,"%f %f %f\n",*px ,*py,*pz);


		px+=4;py+=4;pz+=4;pr+=4;
	}	

	fclose(stream);

	fclose(out_stream);

}



int main()
{

	transger_bin2pcd("000000.bin");

	printf("end\n");

	return 0;
}
